package com.joeyzh.hybrid;

import android.content.Context;
import android.content.SharedPreferences;

import com.joey.base.util.SharedPreferenceUtils;

/**
 * Created by Joey on 2018/11/28.
 *
 * @author by Joey
 *         用于js读取App的存储内容
 */

public class AppCacheJsInterface {

    private Context mCtx;
    private SharedPreferences preferences;

    public AppCacheJsInterface(Context context, String name) {
        mCtx = context;
        preferences = mCtx.getSharedPreferences(name, Context.MODE_PRIVATE);
    }

    public String getValue(String key) {
        return preferences.getString(key, "");
    }

    public void setValue(String key, Object value) {
        SharedPreferences.Editor editor = preferences.edit();
        editor.putString(key, value.toString());
        editor.commit();
    }
}
